var MP = Class.create();
MP.prototype = {
    initialize: function ()
    {
        this.AjaxPath="/Ajax/";
        this.pid = 0;
    },
    
    initTagsSelection: function(base_dom, dom)
    {
        var self = this;
        var arr = dom.value.split(',');
        base_dom.getElementsBySelector('a').each(function(a){
            if (!a.hasClassName('sel') && arr.indexOf(a.title) >= 0) a.addClassName('sel');
            a.observe('click', function(){
                if (a.hasClassName('sel')) a.removeClassName('sel');
                else a.addClassName('sel');
                self.updateTagsField(base_dom, dom);
            });
        });
    },
    
    updateTagsField: function(base_dom, dom)
    {
        dom.value="";
        var arr = new Array();
        base_dom.getElementsBySelector('a.sel').each(function(a){arr.push(a.title);});
        if (arr.size() > 0) dom.value = arr.join(',');
    }
}